package com.dgd.test.demo.globalecxeption;


import com.dgd.test.demo.vo.EduResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @program: 726
 * @description:
 * @author: Jaime
 * @create: 2021-07-28 15:20
 **/
@ControllerAdvice
public class globalException {
    // Logger logger =   LoggerFactory.getLogger(globalException.class);

    @ResponseBody
    @ExceptionHandler(Exception.class)
    public EduResult result(Exception e){

        return  EduResult.error("全局出问题了"+e.getMessage());
    };

    @ResponseBody
    @ExceptionHandler(EduException.class)
    public EduResult customResult(Exception e){

        return  EduResult.error("自定义异常"+e.getMessage());
    };

}
